package cn.tedu.zhyl.base.config;

import cn.tedu.zhyl.base.properties.IotProperties;
import com.aliyun.iot20180120.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class IotConfig {
    @Autowired
    private IotProperties iotProperties;
    @Bean
    public Client instance() throws Exception {
        Config config = new Config();
        config.setAccessKeyId(iotProperties.getAccessKeyId()).getAccessKeyId();
        config.setRegionId(iotProperties.getRegionId());
        config.setAccessKeySecret(iotProperties.getAccessKeySecret());
        Client client = new Client(config);
        return client;
    }
}
